﻿using System;
using System.ComponentModel;

namespace DoNet.ViewFaceCore.Sdk
{
    public class EnumHelper
    {
        public static string GetEnumDescription(Enum enumValue)
        {
            var fi = enumValue.GetType().GetField(enumValue.ToString());
            if (fi != null)
            {
                DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
                return (attributes.Length > 0) ? attributes[0].Description : enumValue.ToString();
            }
            return enumValue.ToString();
        }
    }
}
